﻿function ClientAddGroupNews()
{
    belongSite = document.getElementById("drpSelectSiteGroupNews").options[document.getElementById("drpSelectSiteGroupNews").selectedIndex].value;
    Url=Portal.CMS.GroupNews.GetAddGroupNewUrl(belongSite).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
    //FilterFunc();
}

function ClientSaveAddGroupNews() {
    IsNews = document.getElementById("chkIsNews").checked;
    Subject=document.getElementById("txtGroupNews").value;
    belongSite=document.getElementById("txtBelongSite").value;
    RetValue = Portal.CMS.AddGroupNews.ServerSideAddGroupNews(belongSite, Subject, IsNews).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    window.close();
}

function ClientDeleteGroupNews(GroupNewsId)
{
    retValue = Portal.CMS.GroupNews.ServerSideCheckAllowDelete(GroupNewsId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    Msg = Portal.CMS.GroupNews.GetConfirmDeleteMsg().value;
    if(confirm(Msg)==false)return;
    RetValue = Portal.CMS.GroupNews.ServerSideDeleteGroupNews(GroupNewsId).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    FilterFunc();
}

function ShowClientUpdateUrlForm(GroupNewsId)
{
    Url = Portal.CMS.GroupNews.GetShowUpdateForm(GroupNewsId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
    //FilterFunc();
}

function ClientSaveUpdateGroupNews(GroupNewsId) {
    IsNews = document.getElementById("chkIsNews").checked;
    Subject=document.getElementById("txtGroupNews").value;
    RetValue = Portal.CMS.UpdateGroupNews.ServerSideUpdateGroupNews(GroupNewsId, Subject, IsNews).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    window.close();
}


function ShowClientGroupNewsItemUrlForm(GroupNewsId)
{
    Url = Portal.CMS.GroupNews.GetShowGroupNewsItemsForm(GroupNewsId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    window.open(Url, "_blank");
}


function ClientShowAddGroupNewsItemRootForm(GroupNewsId)
{
    Url = Portal.CMS.GroupNewsItems.GetAddGroupNewsItemFormUrl(GroupNewsId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
    //document.getElementById("divContentData").innerHTML=GroupNewsItems.GetHtml(GroupNewsId).value;
}

function ClientShowAddGroupNewsItemSubForm(GroupNewsId,ParentGroupNewsItemId)
{
    Url = Portal.CMS.GroupNewsItems.GetAddSubGroupNewsItemFormUrl(GroupNewsId, ParentGroupNewsItemId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
    //document.getElementById("divContentData").innerHTML=GroupNewsItems.GetHtml(GroupNewsId).value;
}



function ClientShowUpdateGroupNewsItemSubForm(GroupNewsId,GroupNewsItemId)
{
    Url = Portal.CMS.GroupNewsItems.GetUpdateSubGroupNewsItemFormUrl(GroupNewsId, GroupNewsItemId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
    //document.getElementById("divContentData").innerHTML=GroupNewsItems.GetHtml(GroupNewsId).value;
}

function ClientSaveAddGroupNewsItem(GroupNewsId,ParentGroupNewsItemId)
{
    GroupNewsItemName=document.getElementById("txtGroupNewsItemName").value;
    RssUrl=document.getElementById("txtRssUrl").value;
    JumpUrl=document.getElementById("txtJumpUrl").value;
    IndexOrder=document.getElementById("txtIndexOrder").value;
    ShowInMenu = document.getElementById("chkShowInMenu").checked;
    IsGroupNews = document.getElementById("chkIsGroupNews").checked;
    Description = document.getElementById("txtDescription").value;
    GroupNewsItemAlias = document.getElementById("txtGroupNewsItemAlias").value;
    ShortSubject = document.getElementById("txtShortSubject").value;
    AllowRssIndex = document.getElementById("drpSelectRss").selectedIndex;
    retValue = Portal.CMS.AddGroupNewsItem.ServerSideAddGroupNewsItem(GroupNewsId, GroupNewsItemName, Description, ParentGroupNewsItemId, IndexOrder, RssUrl, JumpUrl, ShowInMenu, IsGroupNews, GroupNewsItemAlias, ShortSubject, AllowRssIndex).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    window.close();
}

function DeleteGroupNewsItem(GroupNewsId,GroupNewsIdItemId)
{
    retValue = Portal.CMS.GroupNewsItems.ServerSideCheckDeleteGroupNewsItem(GroupNewsIdItemId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    ConfirmMsg = Portal.CMS.GroupNewsItems.GetConfirmMsg().value;
    if(confirm(ConfirmMsg)==false)return;
    retValue = Portal.CMS.GroupNewsItems.ServerSideDeleteGroupNewsItem(GroupNewsIdItemId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    alert(retValue);
    document.getElementById("divContentData").innerHTML=GroupNewsItems.GetHtml(GroupNewsId).value;
}

function ClientSaveGroupNewsItem(GroupNewsId,GroupNewsItemId)
{
    GroupNewsItemName=document.getElementById("txtGroupNewsItemName").value;
    RssUrl=document.getElementById("txtRssUrl").value;
    JumpUrl=document.getElementById("txtJumpUrl").value;
    IndexOrder=document.getElementById("txtIndexOrder").value;
    ShowInMenu = document.getElementById("chkShowInMenu").checked;
    ShowInSubMenu = document.getElementById("chkShowInSubMenu").checked;
    IsGroupNews = document.getElementById("chkIsGroupNews").checked;
    Visible = document.getElementById("chkVisible").checked;
    Description = document.getElementById("txtDescription").value;
    GroupNewsItemAlias = document.getElementById("txtGroupNewsItemAlias").value;
    ShortSubject = document.getElementById("txtShortSubject").value;
    language = document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    //AllowRssIndex = document.getElementById("drpSelectRss").selectedIndex;
    AllowRssIndex = 0;
    retValue = Portal.CMS.UpdateGroupNewsItem.ServerSideSaveGroupNewsItem(language, GroupNewsItemId, GroupNewsItemName, Description, IndexOrder, RssUrl, JumpUrl, ShowInMenu, IsGroupNews, Visible, GroupNewsItemAlias, ShortSubject, AllowRssIndex, ShowInSubMenu).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    alert(retValue);
    window.close();
}

function ClientShowNewsItemForms(GroupNewsId)
{
    Url = Portal.CMS.GroupNews.GetShowNewsItemForm(GroupNewsId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
}


function GenerateNewsStaticPage(GroupNewsId)
{
    Url = Portal.CMS.GroupNews.GetGenerateNewsStaticPageUrl(GroupNewsId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
}


function ClientGenerateStaticNewsPage(GroupNewsId)
{
    document.getElementById("divProcessing").innerHTML=GenerateStaticNewsPage.GetProcessingText().value;
    setTimeout("RealClientGenerateStaticNewsPage('"+GroupNewsId+"')",10);
}


function RealClientGenerateStaticNewsPage(GroupNewsId)
{
    TabId=document.getElementById("drpSelectTab").options[document.getElementById("drpSelectTab").selectedIndex].value;
    TabModuleId=document.getElementById("drpSelectModule").options[document.getElementById("drpSelectModule").selectedIndex].value;
    ViewId=document.getElementById("drpSelectView").options[document.getElementById("drpSelectView").selectedIndex].value;
    VisiblePorlet=document.getElementById("divHasPorlet").selectedIndex;
    retValue = Portal.CMS.GenerateStaticNewsPage.ExecuteGeneratePage(GroupNewsId, TabId, TabModuleId, ViewId, VisiblePorlet).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        document.getElementById("divProcessing").innerHTML="";
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML="";
    alert(retValue);
}

function ClientReadingModule()
{
    TabId=document.getElementById("drpSelectTab").options[document.getElementById("drpSelectTab").selectedIndex].value;
    retValue = Portal.CMS.GenerateStaticNewsPage.GetModule(TabId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    document.getElementById("divModuleHolder").innerHTML=retValue;
    ClientGetView();
}

function ClientGetView()
{
    TabModuleId=document.getElementById("drpSelectModule").options[document.getElementById("drpSelectModule").selectedIndex].value;
    retValue = Portal.CMS.GenerateStaticNewsPage.GetView(TabModuleId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    document.getElementById("divViewHolder").innerHTML=retValue;
}


function ShowPermissionFuncForm(GroupNewsId)
{
    Url = Portal.CMS.GroupNews.GetShowFormSetPermission(GroupNewsId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
  
}

function DetectSubjectLanguage(GroupNewsItemId)
{
    language=document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    retValue = Portal.CMS.UpdateGroupNewsItem.GetSubject(language, GroupNewsItemId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    document.getElementById("txtGroupNewsItemName").value = retValue;


    Description = Portal.CMS.UpdateGroupNewsItem.GetDescription(language, GroupNewsItemId).value;
    if (Description.indexOf("ERROR") != -1) {
        alert(Description);
        return;
    }
    document.getElementById("txtDescription").value = Description;
}

function ClientPublishingGroupNewsItemRoot(GroupNewsId,GroupNewsItemId)
{
    retValue = Portal.CMS.GroupNewsItems.ServerSideCheckAllowPublishingGroupNewsItemRoot(GroupNewsId, GroupNewsItemId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    ConfirmMsg = Portal.CMS.GroupNewsItems.GetConfirmPublicMsg().value;
    if(confirm(ConfirmMsg)==false)return;
    retValue = Portal.CMS.GroupNewsItems.GetProcessingText().value;
    document.getElementById("divProcessing").innerHTML=retValue;
    setTimeout("RealClientPublishingGroupNewsItemRoot('"+GroupNewsId+"','"+GroupNewsItemId+"')",10);
}


function RealClientPublishingGroupNewsItemRoot(GroupNewsId,GroupNewsItemId)
{
    document.getElementById("divProcessing").innerHTML="";
    retValue = Portal.CMS.GroupNewsItems.ServerSidePublishingGroupNewsItemRoot(GroupNewsId, GroupNewsItemId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    alert(retValue);
}

function ClientPublishingGroupNewsItemSub(GroupNewsId,GroupNewsItemId,SubGroupNewsItemId)
{
    retValue = Portal.CMS.GroupNewsItems.ServerSideCheckAllowPublishingGroupNewsItemSub(GroupNewsId, GroupNewsItemId, SubGroupNewsItemId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }

    ConfirmMsg = Portal.CMS.GroupNewsItems.GetConfirmPublicMsg().value;
    if(confirm(ConfirmMsg)==false)return;
    retValue = Portal.CMS.GroupNewsItems.GetProcessingText().value;
    document.getElementById("divProcessing").innerHTML=retValue;
    setTimeout("RealClientPublishingGroupNewsItemSub('"+GroupNewsId+"','"+GroupNewsItemId+"','"+SubGroupNewsItemId+"')",10);
}


function RealClientPublishingGroupNewsItemSub(GroupNewsId,GroupNewsItemId,SubGroupNewsItemId)
{
    document.getElementById("divProcessing").innerHTML="";
    retValue = Portal.CMS.GroupNewsItems.ServerSidePublishingGroupNewsItemSub(GroupNewsId, GroupNewsItemId, SubGroupNewsItemId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    alert(retValue);
}


function ClientPermissionGroupNewsItem(GroupNewsId,GroupNewsItemId)
{
    Url = Portal.CMS.GroupNewsItems.GetShowFormSetPermission(GroupNewsItemId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
}





function FilterFunc()
{
    document.getElementById("divProcessing").innerHTML=Portal.CMS.GroupNews.GetProcessingText().value;
    setTimeout("RealFilterFunc()",10);
}


function RealFilterFunc()
{
    belongSite=document.getElementById("drpSelectSiteGroupNews").options[document.getElementById("drpSelectSiteGroupNews").selectedIndex].value;
    retValue = Portal.CMS.GroupNews.GetHtml(belongSite).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        document.getElementById("divProcessing").innerHTML="";
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML="";
    document.getElementById("divGroupNewsMain").innerHTML=retValue;
}


function ClientHtmlItem(GroupNewsId, GroupNewsItemId) {
    Url = Portal.CMS.GroupNewsItems.GetUpdateHtmlUrl(GroupNewsId, GroupNewsItemId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    window.open(Url, '_blank');
}

function ClientSaveGroupNewsItemHtml(GroupNewsItemId) {
    var instanceName = "ctl04";
    var oEditor = FCKeditorAPI.GetInstance(instanceName);
    bodyText = oEditor.GetXHTML(true);
    GroupNewsItemShortContent = document.getElementById("txtGroupNewsItemShortContent").value;
    rValue = Portal.CMS.GroupNewsHtml.ServerSideHtml(GroupNewsItemId, GroupNewsItemShortContent, bodyText).value;
    alert(rValue);
}

function ClientUpdateLevelIndex(GroupNewsId) {
    document.getElementById("divProcessing").innerHTML = Portal.CMS.GroupNewsItems.GetProcessingText().value;
    setTimeout("RealClientUpdateLevelIndex('"+GroupNewsId+"')", 10);
}


function RealClientUpdateLevelIndex(GroupNewsId) {
    rValue = Portal.CMS.GroupNewsItems.ServerSideUpdateLevelIndex(GroupNewsId).value;
    document.getElementById("divProcessing").innerHTML = "";
    alert(rValue);
}


function ClientShowLink(belongSite, GroupNewsItemId) {
    rValue = Portal.CMS.GroupNewsItems.ServerSideGetLink(belongSite, GroupNewsItemId).value;
    document.getElementById("divShowUrl_" + GroupNewsItemId).innerHTML = rValue;
}


function ClientImageItem(GroupNewsId, GroupNewsItemId) 
{
    Url = Portal.CMS.GroupNewsItems.GetImageUrl(GroupNewsId, GroupNewsItemId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
}


function ClientSync(GroupNewsId, GroupNewsItemId) {
    document.getElementById("divProcessing").innerHTML = Portal.CMS.GroupNewsItems.GetProcessingText().value;
    setTimeout("RealClientSync('" + GroupNewsId + "','" + GroupNewsItemId + "')", 10);
}

function RealClientSync(GroupNewsId, GroupNewsItemId) {
    rValue = Portal.CMS.GroupNewsItems.ServerSideSync(GroupNewsItemId).value;
    document.getElementById("divProcessing").innerHTML = "";
    alert(rValue);
}


function ClientSyncWithNews(GroupNewsId, GroupNewsItemId) {
    document.getElementById("divProcessing").innerHTML = Portal.CMS.GroupNewsItems.GetProcessingText().value;
    setTimeout("RealClientSyncWithNews('" + GroupNewsId + "','" + GroupNewsItemId + "')", 10);
}

function RealClientSyncWithNews(GroupNewsId, GroupNewsItemId) {
    rValue = Portal.CMS.GroupNewsItems.ServerSideSyncWithNews(GroupNewsItemId).value;
    document.getElementById("divProcessing").innerHTML = "";
    alert(rValue);
}

function ClientReadingGroupNewsItem(GroupNewsId) {
    Processing = Portal.CMS.GroupNewsItems.GetProcessingText().value;
    document.getElementById("divProcessing").innerHTML = Processing;
    setTimeout("RealClientReadingGroupNewsItem('"+GroupNewsId+"')", 10);
}

function RealClientReadingGroupNewsItem(GroupNewsId) {
    Html = Portal.CMS.GroupNewsItems.GetHtml(GroupNewsId).value;
    document.getElementById("divContentData").innerHTML = Html;
    document.getElementById("divProcessing").innerHTML = "";
}